package com.example.bitintershipbbs.mapper;

import com.example.bitintershipbbs.model.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Insert("insert into dbuser(email,name,psw,gmt_create,gmt_modified,token,follower_count) values (#{email},#{name},#{psw},#{gmt_create},#{gmt_modified},#{token},#{follower_count})")
    void createUser(User user);

    @Select("select * from dbuser where email = #{email}")
    User findByEmail(@Param("email") String email);

    @Select("select * from dbuser where name = #{username}")
    User findByUsername(@Param("username") String username);

    @Select("select * from dbuser where token = #{token}")
    User findByToken(@Param("token") String token);

    @Select("select * from dbuser where id = #{id}")
    User findById(@Param("id") int id);

    @Update("update dbuser set avatar_url=#{avatar_url} where id = #{id}")
    void addAvatar(User user);
}
